package com.ruoyi.web.controller.teaching;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.teaching.domain.PlatformFReport;
import com.ruoyi.teaching.service.PlatformFReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王旭
 * @since 2025-02-11
 */
@RestController
@RequestMapping("/platform/report")
@Api(tags = "platform-违规举报管理")
public class PlatformFReportController {
    @Autowired
    private PlatformFReportService platformFReportService;

    /**
     * 分页查询所有违规举报
     */
    @GetMapping("/allReport")
    @ApiOperation(value = "分页查询所有违规举报", notes = "分页查询所有违规举报")
    public AjaxResult allReport(
            Integer pageNum, Integer pageSize, String reportTitle, Integer reportStatus, Integer reportType, Integer reportTime
            ) {
        return platformFReportService.allReport(pageNum, pageSize, reportTitle, reportStatus, reportType, reportTime);
    }

    /**
     * 处理举报（可批量）
     */
    @PutMapping("/dealReport")
    @ApiOperation(value = "处理举报（可批量）", notes = "处理举报（可批量）")
    @Log(title = "【处理举报（可批量）】", businessType = BusinessType.UPDATE)
    public AjaxResult dealReport(@RequestBody List<PlatformFReport> reports) {
        return platformFReportService.dealReport(reports);
    }

    /**
     * 新增举报
     */
    @PostMapping("/addReport")
    @ApiOperation(value = "新增举报", notes = "新增举报")
    @Log(title = "【新增举报】", businessType = BusinessType.INSERT)
    public AjaxResult addReport(@RequestBody PlatformFReport platformFReport) {
        if(StringUtils.isEmpty(platformFReport.getReportMessage())){
            return AjaxResult.error("举报内容不能为空");
        }
        if(StringUtils.isEmpty(platformFReport.getReportTitle())){
            return AjaxResult.error("举报标题不能为空");
        }
        if(null == platformFReport.getReportType()){
            return AjaxResult.error("举报类型不能为空");
        }
        return platformFReportService.addReport(platformFReport);
    }

    /**
     * 删除举报
     */
    @DeleteMapping("/deleteReport/{ids}")
    @ApiOperation(value = "删除举报", notes = "删除举报")
    @Log(title = "【删除举报】", businessType = BusinessType.DELETE)
    public AjaxResult deleteReport(@PathVariable("ids") Long[] ids) {
        return platformFReportService.deleteReportByIds(ids);
    }

    /**
     * 查看违规举报详情
     */
    @GetMapping("/reportDetail/{id}")
    @ApiOperation(value = "查看违规举报详情", notes = "查看违规举报详情")
    public AjaxResult reportDetail(@PathVariable("id") Long id) {
        return platformFReportService.reportDetail(id);
    }

}

